package shiyan2;

import java.util.ArrayList;
import java.util.List;

public class Student {
    private String studentId;
    private String studentName;
    private String gender;
    private List<Course> selectedCourses = new ArrayList<>();

    public Student(String studentId, String studentName, String gender) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.gender = gender;
    }

    // 学生选课方法
    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(studentName + "同学选择了课程：" + course.getCourseName());
    }

    // 学生退课方法
    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(studentName + "同学退选了课程：" + course.getCourseName());
        } else {
            System.out.println(studentName + "同学未选择该课程，无法退选");
        }
    }

    // 打印学生课表方法
    public void printCourseSchedule() {
        System.out.println(studentName + "同学的课表：");
        for (Course course : selectedCourses) {
            System.out.println("课程编号：" + course.getCourseId() + "，课程名称：" + course.getCourseName() + "，上课地点：" + course.getLocation() + "，时间：" + course.getTime());
        }
    }

    // Getters and Setters
    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }

    public void setSelectedCourses(List<Course> selectedCourses) {
        this.selectedCourses = selectedCourses;
    }

    @Override
    public String toString() {
        return "Student{" +
                "studentId='" + studentId + '\'' +
                ", studentName='" + studentName + '\'' +
                ", gender='" + gender + '\'' +
                ", selectedCourses=" + selectedCourses +
                '}';
    }
}
